package offer;



/**
 * 描述:
 *
 * @author Madison You
 * @created 23:54
 */
public class Easy_06_ReversePrint {

    public static void main(String[] args) {
        ListNode node = ListNode.createNode(new int[]{1, 3, 2});
        new Easy_06_ReversePrint().reversePrint(node);
    }

    public int[] reversePrint(ListNode head) {

        ListNode pre = null;
        ListNode curr = head;
        int i = 0;
        while (curr != null) {
            i++;
            ListNode temp = curr.next;
            curr.next = pre;
            pre = curr;
            curr = temp;
        }

        int[] ints = new int[i];
        int j = 0;
        while (pre != null) {
            ints[j++] = pre.val;
            pre = pre.next;
        }

        return ints;
    }

}
